import React from 'react';
import { connect } from 'dva';
import 'antd-mobile/dist/antd-mobile.css';
import Banner from "../components/Banner";
import { NavBar,Card } from 'antd-mobile';
import { routerRedux } from 'dva/router';
import {PriceDataList} from "../components/PriceDetailComponent";
@connect(({ cars }) => ({
  store: cars,
}))


// 价格查询详情
export default class PriceDetail extends React.Component{

  componentDidMount(){
    console.log(this.props.store);
    var {activeBrand,activeSeries,formData} = this.props.store ;
    var brandId = activeBrand.value ;
    var seriesId = activeSeries.value ;
    var {name,phone} = formData ;

    this.props.dispatch({
      type:'cars/search_price',
      payload:{
        nickName:name,
        mobilePhone:phone,
        seriesId:seriesId,
        modelId:brandId
      }
    })
  }

  render(){
    var {priceDetail} = this.props.store;
    return (
      <div>
        <NavBar
          mode="dark"
          leftContent={'返回'}
          onLeftClick={() => {
            this.props.dispatch(routerRedux.goBack());
          }}
        >查询结果</NavBar>
        <Banner/>
        <Card>
          {
            Object.keys(priceDetail).map((d,index)=>{
              var title = d ;
              var list = priceDetail[d] ;
              return  <PriceDataList key={index+'#'} title={title} list={list}/>
            })
          }
        </Card>
      </div>
    );
  }
}



